package com.qf.flash.ui.chat.rowProvider;

import android.widget.BaseAdapter;

import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.EaseConstant;
import com.hyphenate.easeui.widget.chatrow.EaseCustomChatRowProvider;
import com.hyphenate.easeui.widget.presenter.EaseChatRowPresenter;

/**
 * 描述:
 * 2020/5/6 15:57
 */
public class MyEaseChatProvider implements EaseCustomChatRowProvider {
    @Override
    public int getCustomChatRowTypeCount() {
        return 2;
    }

    @Override
    public int getCustomChatRowType(EMMessage message) {
        if (message.getType() == EMMessage.Type.TXT) {
            return message.direct() == EMMessage.Direct.RECEIVE ? 0:  1;
        }
        return 0;
    }

    @Override
    public EaseChatRowPresenter getCustomChatRow(EMMessage message, int position, BaseAdapter adapter) {
        if (message.getType() == EMMessage.Type.TXT) {
            if (message.getBooleanAttribute(EaseConstant.CHAT_TYPE_INVITE, false))
                return new EaseChatImgTextPresenter();
        }
        return null;
    }
}
